var EditArea_snippets = {
    /**
    * Get called once this file is loaded (editArea still not initialized)
    *
    * @return nothing	 
    */
    init: function () {
        //	alert("test init: "+ this._someInternalFunction(2, 3));
        editArea.load_css(this.baseURL + "css/test.css");
    }
    /**
    * Returns the HTML code for a specific control string or false if this plugin doesn't have that control.
    * A control can be a button, select list or any other HTML item to present in the EditArea user interface.
    * Language variables such as {$lang_somekey} will also be replaced with contents from
    * the language packs.
    * 
    * @param {string} ctrl_name: the name of the control to add	  
    * @return HTML code for a specific control or false.
    * @type string	or boolean
    */
    , get_control_html: function (ctrl_name) {
        switch (ctrl_name) {
            case "snippets_select":
                html = "<select id='snippet_select' onchange='javascript:editArea.execCommand(\"snippet_select_change\")' fileSpecific='no'>"
                    + "			<option value='-1'>{$snippet_select}</option>"
                    + "			<option value='h1'>h1</option>"
                    + "			<option value='h2'>h2</option>"
                    + "			<option value='h3'>h3</option>"
                    + "			<option value='h4'>h4</option>"
                    + "			<option value='h5'>h5</option>"
                    + "			<option value='h6'>h6</option>"
                    + "		</select>";
                return html;
        }
        return false;
    }
    /**
    * Get called once EditArea is fully loaded and initialised
    *	 
    * @return nothing
    */
    , onload: function () {
    }

    /**
    * Is called each time the user touch a keyboard key.
    *	 
    * @param (event) e: the keydown event
    * @return true - pass to next handler in chain, false - stop chain execution
    * @type boolean	 
    */
    , onkeydown: function (e) {
        return true;
    }

    /**
    * Executes a specific command, this function handles plugin commands.
    *
    * @param {string} cmd: the name of the command being executed
    * @param {unknown} param: the parameter of the command	 
    * @return true - pass to next handler in chain, false - stop chain execution
    * @type boolean	
    */
    , execCommand: function (cmd, param) {
        // Handle commands
        switch (cmd) {
            case "snippet_select_change":
                var val = document.getElementById("snippet_select").value;
                if (val != -1) parent.editAreaLoader.insertTags(editArea.id, val);
                document.getElementById("snippet_select").options[0].selected = true;
                return false;
        }
        // Pass to next handler in chain
        return true;
    }

    /**
    * This is just an internal plugin method, prefix all internal methods with a _ character.
    * The prefix is needed so they doesn't collide with future EditArea callback functions.
    *
    * @param {string} a Some arg1.
    * @param {string} b Some arg2.
    * @return Some return.
    * @type unknown
    */
    , _someInternalFunction: function (a, b) {
    }
};

// Adds the plugin class to the list of available EditArea plugins
editArea.add_plugin("snippets", EditArea_snippets);
